package com.dujiu.leetcode.slidingWindow.fixed_lengthSlidingWindow;

import java.util.Arrays;

public class P1984 {
    public int minimumDifference(int[] nums, int k) {
        int n = nums.length;
        Arrays.sort(nums);
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i+k-1 < n; i++) {
            ans = Math.min(ans,nums[i+k-1] - nums[i]);
        }
        return ans;
    }
}
